<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>审批业务仿真</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function addRow(){
	doSubmit({actionType:'addBizData',doValidate:'false'});
}
function deleteRow(index){
	$("#bizDataIndex").val(index);
	doSubmit({actionType:'delBizData',doValidate:'false'});
}

var procGraphBox;
function showProcGraphBox(){
	if (!procGraphBox){
		procGraphBox = new PopupBox('procGraphBox','流程定义图',{width:'900px',height:'500px',top:'10px',scroll:'yes'});		
	}	
	var url = "index?WfProcessInstanceView&actionType=prepareDisplay&WFIP_ID="+$('#WFIP_ID').val() +"&WFP_ID="+$('#WFP_ID').val();
	procGraphBox.sendRequest(url);
}

var varIndex = 0;
var prcocessVarListBox;
function showPrcocessVarList(index){
	varIndex = index;
	if (!prcocessVarListBox){
		prcocessVarListBox = new PopupBox('prcocessVarListBox','请选择流程变量',{size:'big'}); 
	}
	prcocessVarListBox.sendRequest('index?WfProcessVariableSelect&WFP_ID='+$('#WFP_ID').val());
}

function fillProcessVar(lable,code,value){
	$("#bizDataName_"+varIndex).val(lable);
	$("#bizDataCode_"+varIndex).val(code);
	$("#bizDataValue_"+varIndex).val(value);
}

function resetParentHeight(){
	var id = 'detailFrame';
	var frm=document.getElementById(id);
	var subWeb=document.frames?document.frames[id].document:frm.contentDocument;
	if (document.getElementById){
		if (frm && !window.opera){
			if (frm.contentDocument && frm.contentDocument.body.offsetHeight){
			 	frm.height = frm.contentDocument.body.offsetHeight;
			}			
			else if(frm.Document && frm.Document.body.scrollHeight){
				frm.height = (subWeb.body.scrollHeight+20)+"px";
			}
		}
	}
}
function submitProcess(){
	var bizDataSize = parseInt($('#bizDataSize').val());
	for (var i=0;i < bizDataSize;i++){		
		var code = $('#bizDataCode_'+i).val();
		var name = $('#bizDataName_'+i).val();
		var value = $('#bizDataValue_'+i).val();		
		if (validation.checkNull(code) || validation.checkNull(name)
			|| validation.checkNull(value)){
			writeErrorMsg('字段名称、字段编码、编码值都不能为空！');
			return;			
		}
		if (!validation.isRawChar(code)){
			writeErrorMsg('字段编码只能由数字、字母或者下划线组成！');
			ele('bizDataCode_'+i).focus();
			return;
		}	
	}
	doSubmit({actionType:'submit'});
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div id="__ParamBar__" style="float: right;">&nbsp;</div>
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr height="24px;">
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="submitProcess()"><input id="transImgBtn" value="&nbsp;" type="button" class="transImgBtn" title="提交" />提交</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="V" class="bartdx" align="center" onClick="showProcGraphBox()"><input value="&nbsp;" type="button" class="flowStateImgBtn" title=流程图" />流程图</td>   
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="doSubmit({actionType:'back',doValidate:'false'})"><input value="&nbsp;" type="button" class="backImgBtn" title="返回" />返回</td>
</tr>
</table>
</div>
<div style="margin:0px">
<iframe name="detailFrame" id="detailFrame" width="99%" height="270" src="<%=pageBean.inputValue("businessDetailURL")%>" marginwidth="0" marginheight="0" style="padding:0;" frameborder="0" scrolling="auto"></iframe>
</div>
<table id="dataTable" class="dataTable" cellspacing="0"  cellpadding="0">
  <tr>
    <th width="30%" align="center" nowrap="nowrap">名称</th>
    <th width="30%" align="center">字段编码</th>
    <th width="30%" align="center" nowrap="nowrap">字段值</th>
    <th width="80" align="center" nowrap="nowrap"><input class="formbutton"type="button" name="button7" id="button7" value="新增" onClick="addRow()"/></th>
  </tr>
<%
pageBean.initListAttribute("bizDataList");
int varSize = pageBean.listSize();
for (int i=0;i < varSize;i++){
%>  
  <tr ondblclick="showPrcocessVarList(<%=i%>)">
    <td align="center" nowrap="nowrap"><input name="bizDataName_<%=i%>" readonly="readonly" type="text" id="bizDataName_<%=i%>" size="20" value="<%=pageBean.inputValue(i,"bizDataName") %>" /></td>
    <td align="center"><input name="bizDataCode_<%=i%>" readonly="readonly" type="text" id="bizDataCode_<%=i%>" size="16" maxlength="16" value="<%=pageBean.inputValue(i,"bizDataCode") %>"/></td>
    <td align="center"><input name="bizDataValue_<%=i%>" type="text" id="bizDataValue_<%=i%>" value="<%=pageBean.inputValue(i,"bizDataValue") %>" size="20" maxlength="20"/></td>
    <td align="center" nowrap="nowrap" style="text-align:center"><input class="formbutton" type="button" name="delBtn_<%=i%>" id="delBtn_<%=i%>" value="删除" onclick="deleteRow(<%=i%>)"/></td>
  </tr>
<%}%>
</table>
<input type="hidden" name="bizDataSize" id="bizDataSize" value="<%=pageBean.inputValue("bizDataSize") %>"/>
<input type="hidden" name="bizDataIndex" id="bizDataIndex" value="" />
<input type="hidden" name="actionType" id="actionType" value="" />
<input type="hidden" name="operaType" id="operaType" value="<%=pageBean.getOperaType()%>" />
<input type="hidden" name="WFIP_BUSINESS_ID" id="WFIP_BUSINESS_ID" value="<%=pageBean.inputValue("WFIP_BUSINESS_ID")%>" />
<input type="hidden" name="WFIP_ID" id="WFIP_ID" value="<%=pageBean.inputValue("WFIP_ID")%>" />
<input type="hidden" name="WFP_ID" id="WFP_ID" value="<%=pageBean.inputValue("WFP_ID")%>" />
<input type="hidden" name="WFA_CODE" id="WFA_CODE" value="<%=pageBean.inputValue("WFA_CODE")%>" />
<input type="hidden" name="WFA_NAME" id="WFA_NAME" value="<%=pageBean.inputValue("WFA_NAME")%>" />
</form>
</body>
</html>
<script>
$(function(){
	<% if (!pageBean.getBoolValue("canSubmit")){%>
	disableButton("transImgBtn");
	<%}%>
});
</script>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
